import { Modal } from 'ant-design-vue';
import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled, ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { jiraModal } from '@/components/Modal/JiraModal/createJiraModal';
import { h } from 'vue';
// 获取不同类型的icon
// const getIcon = (type: 'warning' | 'info' | 'success' | 'danger') => {
//     switch (type) {
//         case 'warning': return <InfoCircleFilled class="modal-icon-warning" />;
//         case 'info': return <InfoCircleFilled class="modal-icon-info" />;
//         case 'success': return <CheckCircleFilled class="modal-icon-success" />;
//         default: return <CloseCircleFilled class="modal-icon-error" />;
//     }
// };
const getIcon = (type: 'warning' | 'info' | 'success' | 'danger') => {
    switch (type) {
        case 'warning': return h(ExclamationCircleOutlined, { class: 'modal-icon-warning' });
        case 'info': return h(InfoCircleFilled, { class: 'modal-icon-info' });
        case 'success': return h(CheckCircleFilled, { class: 'modal-icon-success' });
        default: return h(CloseCircleFilled, { class: 'modal-icon-error' });
    }
};
// 创建confirm
const createConfirm = (options: any) => {
    if (options.iconType) {
        options.icon = getIcon(options.iconType);
        // 提醒样式
        if (options.iconType === 'danger') {
            options.okButtonProps = {
                danger: true
            };
        }
        // 警告样式
        if (options.iconType === 'warning') {
            options.okButtonProps = {
                style: { background: '#FE9339', borderColor: '#FE9339' }
            };
        }
        // 警告样式
        if (options.iconType === 'success') {
            options.okButtonProps = {
                style: { background: '#26a971', borderColor: '#26a971' }
            };
        }
        Reflect.deleteProperty(options, 'iconType');
    }
    return Modal.confirm({
        ...options
    });
};

// 创建jira登陆
const createJiraLogin = (options: any) => {
    return jiraModal.open({
        ...options
    });
};
export const useMessage = () => ({ createConfirm, createJiraLogin });